package com.example.train.business.controller.admin;

import com.example.train.business.req.Train_StationQueryReq;
import com.example.train.business.req.Train_StationSaveReq;
import com.example.train.business.resp.Train_StationQueryResp;
import com.example.train.business.service.Train_StationService;
import com.example.train.common.resp.CommonResp;
import com.example.train.common.resp.PageResp;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/train_Station")

public class Train_StationAdminController {

    @Resource
    private Train_StationService train_StationService;

    /**
     * 乘客注册请求的controller类，用于调用service
     * 注意PostMapping必须要用requestBody注解，否则后端接受不到数据
     * @param train_StationSaveReq
     * @return
     */
    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody Train_StationSaveReq train_StationSaveReq) {
        train_StationService.save(train_StationSaveReq);
        return new CommonResp<>();
    }
    /**
     * 查询当前会员下乘客信息列表的controller类，用于调用service
     * 注意GetMapping不用requestBody注解，否则后端接受不到数据
     * @param @VALID Train_StationQueryReq
     * @return CommonResp<PageResp<Train_StationQueryResp>>
     */
    @GetMapping("/query-list")
    public CommonResp<PageResp<Train_StationQueryResp>> queryList(@Valid Train_StationQueryReq req) {
        PageResp<Train_StationQueryResp> list = train_StationService.queryList(req);
        return new CommonResp<>(list);
    }

    /**
     * 删除乘客信息的controller层接口
     * @param id
     * @return CommonResp<Object>
     */
    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        train_StationService.delete(id);
        return new CommonResp<>();
    }

}

